Project 3
Code
/// Name: Josh Bautista
/// Period: 6
/// Date Finished: 9/22/2015
import java.util.Random;
import java.util.Scanner;
public class PBJ
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner( System.in);
Random r = new Random();
int d1 = 1 + r.nextInt(11);
int d2 = 1 + r.nextInt(11);
int d3 = 1 + r.nextInt(11);
int d4 = 1 + r.nextInt(11);
int d5 = 1 + r.nextInt(11);
String hs;
System.out.println(" Welcome to BlackJack! ");
System.out.println(" You drew " + d1 + " and " + d2 + ".");
int total = d1 + d2;
System.out.println(" Your total is " + total + "." );
System.out.println("");
System.out.println(" The dealer has " + d3 + " and a hidden card.");
int total2 = d3 + d4;
System.out.println(" The dealer's totals is hidden.");
System.out.println(" Would you like to 'hit or 'stay' ?");
hs = keyboard.next();
while (hs.equals("hit"))
{
System.out.println(" You drew a "+ d5 + ".");
int totalP = total + d5;
System.out.println(" Your total is now " + totalP + ".");
System.out.println(" Would you like to 'hit or 'stay' ?");
hs = keyboard.next();
}
}
}
Picture of the output